home *** CD-ROM | disk | FTP | other *** search
- /* XGStdCheckButton
- *
- * This puts up a standard push button. This uses the standard
- * OS push button if it is available
- */
-
- /* YAAF - Yet another application framework
- * Copyright (C) 1997 William Edward Woody and In Phase Consulting
- *
- * This library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Library
- * General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or any
- * later version.
- *
- * This library is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Library General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * To contact the author, either e-mail me at
- * woody@alumni.caltech.edu, or write to us at
- *
- * William Edward Woody
- * In Phase Consulting
- * 1545 Ard Eevin Avenue
- * Glendale, CA 91202
- */
-
- #include <XApplication.h>
- #include <XStdControls.h>
- #include <XStdButtons.h>
- #include <XWindow.h>
- #include <XError.h>
- #include <XDataUtil.h>
-
- /************************************************************************/
- /* */
- /* Construction/Destruction */
- /* */
- /************************************************************************/
-
- /* XGStdCheckButton::XGStdCheckButton
- *
- * create a push button
- */
-
- XGStdCheckButton::XGStdCheckButton(XGView *view, XGArgStream &stream) :
- XGStdButton(view,stream,true)
- {
- char title[256];
- stream.GetString(sizeof(title),title);
- Init(title);
- }
-
- XGStdCheckButton::XGStdCheckButton(XGView *view, XGSButtonInitRecord &i) :
- XGStdButton(view,i.v,true)
- {
- Init(i.title);
- }
-
- /* XGStdCheckButton::~XGStdCheckButton
- *
- * Delete me
- */
-
- XGStdCheckButton::~XGStdCheckButton()
- {
- }
-
- /************************************************************************/
- /* */
- /* Internal initialization */
- /* */
- /************************************************************************/
-
- void XGStdCheckButton::Init(char *title)
- {
- long l;
-
- l = GetParent()->ReceiveDispatch(KEventGetFont,GetViewID(),(void *)&this);
- #if OPT_MACOS == 1
- XGDraw draw(this,false);
- Rect r;
-
- /*
- * Create the control at this location
- */
-
- ::TextFont(fFont = GETHIWORD(l));
- ::TextSize(fSize = GETLOWORD(l));
-
- r = GetContentRect();
- ViewToGlobal(&r);
- fControl = NewControl(GetWindow()->_GetGrafPtr(), // window owner
- &r, // where
- c2pstr(title), // title
- true, // visible
- 0, // initial value
- 0, // min value
- 1, // max value
- checkBoxProc | kControlUsesOwningWindowsFontVariant, // push button proc
- 0); // refcon
- if (fControl == NULL) {
- throw XPostError("Unable to make button ^S",p2cstr((unsigned char *)title));
- }
- #endif
-
- #if OPT_WINOS == 1
- Rect r;
- HWND w;
-
- /*
- * Get the location of the control in the parent's coordinate
- * system
- */
-
- r = GetContentRect();
- if (GetParent()) {
- ViewToGlobal(&r);
- GetParent()->GlobalToView(&r);
- }
-
- /*
- * Create the control window
- */
-
- w = CreateWindow("BUTTON", // control class
- title, // control title
- WS_CHILD | BS_CHECKBOX, // control window flags
- r.left,
- r.top,
- r.right-r.left,
- r.bottom-r.top, // control location
- GetParent()->_GetHWND(), // container window
- NULL, // no menu
- _GInstance, // My app instance
- NULL); // no additional args
- if (w == NULL) {
- throw XPostError("Unable to make button ^S",title);
- }
-
- _SetHWND(w); // set me as the window
- SetProp(w,_GViewClass,(HANDLE)this);
- if (IsVisible()) ShowWindow(w,SW_SHOW);
- EnableWindow(w,IsEnabled()); // set me up
- #endif
- }
-
-